<template>
  <div>
    <template v-if="componentType === 1">
      <div class="wencai-wrap1">
        <img
          src="//i.thsi.cn/staticS3/mobileweb-upload-static-server.img/m/atom/511ddc94-1563-46d9-86bb-10c46757c688.png"
          class="wencai-logo"
          alt=""
        />
        <div class="iwencai_input_box" @click.stop="askWencai(askText)">
          {{ askText }}
        </div>
      </div>
    </template>
    <template v-if="componentType === 2">
      <div class="wencai-wrap2">
        <img
          src="//i.thsi.cn/staticS3/mobileweb-upload-static-server.img/m/atom/2c91c006-6605-437d-8000-0c9ccfa4c2df.png"
          class="wencai-logo"
          alt=""
        />
        <atom-swipe vertical class="iwencai_swipe" :autoplay="10000" :show-indicators="false">
          <atom-swipe-item v-for="txt in askTextList" @click.stop="askWencai(txt)">{{ txt }}</atom-swipe-item>
        </atom-swipe>
      </div>
      <div class="placeholder"></div>
    </template>
  </div>
</template>
<script>
import config from '@/config/index.ts';
const {
  stat: { oldPageId },
} = config;
export default {
  name: 'AiWencai',
  props: {
    // 组件类型
    componentType: {
      type: Number,
      required: true,
      default: 1,
    },
    // 股票代码
    stockCode: {
      type: String,
      default: '',
    },
    // 市场代码
    marketId: {
      type: String,
      default: '',
    },
    // 是否开启黑夜模式
    openTheme: {
      type: Boolean,
      default: false,
    },
    askText: {
      type: String,
      default: '',
    },
    // 问句列表
    askTextList: {
      type: Array,
      required: true,
      default: () => [],
    },
  },
  methods: {
    // 跳转问财
    askWencai(txt) {
      if (+this.componentType === 2) {
        window.hxmClickStat(`${oldPageId}.shouyeaime`);
      }
      // android半屏有问题 先ios半屏: 2724，android全屏: 2719，都使用client协议
      const webid = window.getPlatform() === 'iphone' ? '2724' : '2719';
      const wencaiUrl = `client://client.html?action=ymtz^webid=${webid}^comefrom=ShouchaoLimitUp^datajson={"source":"ths_zhangtingzhushou_aime"}^query=`;
      const query = txt || '涨停基因超过50分以上的股票';
      location.href = wencaiUrl + query;
    },
  },
};
</script>

<style lang="less" scoped>
.wencai-wrap1 {
  width: 100%;
  height: 52px;
  background: #f7f9ff;
  border-radius: 0.08rem;
  box-sizing: border-box;
  text-align: center;
  display: flex;
  align-items: center;
  .wencai-logo {
    width: 0.52rem;
    height: 0.52rem;
    margin-right: 0.12rem;
  }
  .iwencai_input_box {
    font-family: PingFangSC-Regular;
    font-size: 24px;
    color: rgba(0, 0, 0, 0.84);
    letter-spacing: 0;
    line-height: 36px;
    font-weight: 400;
    margin-top: 4px;
    width: calc(100% - 0.52rem);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: left;
  }
}
.placeholder {
  width: 100vw;
  height: 100px;
}
.wencai-wrap2 {
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 100px;
  box-sizing: border-box;
  text-align: center;
  padding: 14px 32px;
  background: #ffffff;
  border-top: solid 1px #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 12;
  margin-bottom: env(safe-area-inset-bottom);

  .wencai-logo {
    width: 0.52rem;
    height: 0.52rem;
  }
  .iwencai_swipe {
    background: #f7f9ff;
    border-radius: 35px;
    margin-left: 20px;
    width: 100%;
    text-align: left;
    height: 72px;
    line-height: 72px;
    /deep/.atom-swipe-item {
      font-family: PingFangSC-Regular;
      font-size: 28px;
      color: rgba(0, 0, 0, 0.85);
      letter-spacing: 0;
      text-align: justify;
      font-weight: 400;
      margin-left: 28px;
    }
  }
}
</style>
